package com.app.AppWidget;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import com.app.AppWidget.R;
import com.app.AppWidget.AppWidget;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.widget.RemoteViews;

public class AppWidget extends AppWidgetProvider {

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		// TODO Auto-generated method stub
		super.onUpdate(context, appWidgetManager, appWidgetIds);
		
		RemoteViews remoteViews;
        ComponentName watchWidget;
        
        DateFormat format = 
        	SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault());

        remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
        watchWidget = new ComponentName(context, AppWidget.class);
        
        remoteViews.setTextViewText(R.id.widget_textview, format.format(new Date()));
        appWidgetManager.updateAppWidget(watchWidget, remoteViews);				
	}

}
